function a=zoom_(alow,ahigh,x,p,c1,c2,f0,f1)
% Zoom to select a proper step length value given an interval;
% based on Algorithm 3.6 on Numerical optimization NW2 p61
% INPUT:
%       alow - the low bound of the interval;
%       ahigh - the upper bound of the interval;
%       x - current iterate;
%       c1 - constant for goldstein condition;
%       c2 - constant for the strong wolfe condition;
%       f0 - objective function;
%       f1 - gradient function;
% OUTPUT:
%       a - selected step length;
% REVISION:
%       jqin, 18/feb/2011;
while 1==1
a=interpolate_(alow,ahigh);
if (goldsteins(a,x,p,c1,f0,f1)||f0(x+a*p) >= f0(x+alow*p))
    ahigh=a;
else
    if swolfe(a,x,p,c2,f1)
        break;
    end
    if f1(x+a*p)*(ahigh-alow)>=0
        ahigh=alow;
    end
    alow=aj;
end
end